//
//  PK-ios
//
//  Created by Seven on 15/9/15.
//  Copyright (c) 2015年 Seven. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MBProgressHUD/MBProgressHUD.h>
NS_ASSUME_NONNULL_BEGIN

@interface UIView (Category)

@property(nonatomic, assign)NSInteger customIndex;

+ (instancetype _Nullable )initWithFrame:(CGRect)frame;
- (void)initViews;

+ (instancetype)lineView;
+ (instancetype)lineWithFrame:(CGRect)frame color:(UIColor * _Nullable)c;
- (void)addLineWithFrame:(CGRect)frame;
- (void)appendBorderLine:(int)direction width:(float)w color:(UIColor* _Nullable)c;
- (void)addLineWithFrame:(CGRect)frame color:(UIColor * _Nullable)c;

- (CAGradientLayer *)gradientColorWithStartPoint:(CGPoint)startPoint toPoint:(CGPoint)toPoint fromColor:(UIColor *)fromColor toColor:(UIColor *)toColor locations:(NSArray *)locations;
- (CAGradientLayer *)gradientColorWithStartPoint:(CGPoint)startPoint toPoint:(CGPoint)toPoint colors:(NSArray *)colors locations:(NSArray *)locations;
@end

@interface UIView (Screenshot)

//View截图
- (UIImage*) screenshot;

-(UIImage *)screenshotScale:(CGFloat)scale;

//ScrollView截图 contentOffset
- (UIImage*) screenshotForScrollViewWithContentOffset:(CGPoint)contentOffset;

//View按Rect截图
- (UIImage*) screenshotInFrame:(CGRect)frame;

@end

@interface UIView (Animation)

- (void)moveAnimation;

//弹出动画（弹窗用）
- (void) springingAnimation;

//旋转180度
- (void) trans180DegreeAnimation;

//点赞动画
- (void) praiseAnimation;


- (void) shakeAnimation;
- (void) shakeAnimation2;

- (void) scaleAnimation;
- (void) scaleAnimation:(CGFloat)scale;

- (void) rotateAnimation;

- (void) rotateAnimationY;

- (void) fadeAnimation;

- (void) popAnimation;

- (void) pushAnimation;

- (void)startLikeAnimationWithAppearanceConfig:(void (^)(void))config completion:(void (^)(void))completion;



/** 暂停动画*/
- (void)pauseAnimation;

/**恢复动画*/
- (void)resumeAnimation;

@end


@interface UIView (Corner)
@property(nonatomic,strong)CAShapeLayer * currentShapeLayer;

- (void)addAllCornerWithSize:(CGSize)aSize;

- (void)addCornerWithType:(UIRectCorner)aCorners
                     size:(CGSize)aSize;

- (void)addCornerWithType:(UIRectCorner)aCorners
                     size:(CGSize)aSize
              borderColor:(UIColor*)borderColor
              borderWidth:(CGFloat)borderWidth;

-(UIImage *)convertToImage;

- (nullable NSArray *)calculateFourPointsInRateStyle;
@end


@interface CALayer(extension)


//lineView
+ (instancetype _Nonnull )lineWithFrame:(CGRect)frame color:(UIColor *_Nonnull)color;

+ (id _Nonnull )maskLayerWithCorners:(UIRectCorner)corners radii:(CGSize)radii frame:(CGRect)frame;


+ (CAGradientLayer *)gradientColorWithStartPoint:(CGPoint)startPoint toPoint:(CGPoint)toPoint fromColor:(UIColor *)fromColor toColor:(UIColor *)toColor locations:(NSArray *)locations;

+ (CAGradientLayer *)gradientColorWithStartPoint:(CGPoint)startPoint toPoint:(CGPoint)toPoint colors:(NSArray *)colors locations:(NSArray *)locations;

+ (CALayer *)layerWithImage:(id)image frame:(CGRect)frame;


/** 暂停动画*/
- (void)pauseAnimation;

/**恢复动画*/
- (void)resumeAnimation;

@end


@interface UIView(loading)

- (MBProgressHUD *)showLoading;

- (MBProgressHUD *)showLoadingWithTitle:(NSString *)title;

- (void)hideLoading;

- (void)hideLoading:(BOOL)animation;


- (void)showInfo:(NSString *)text;
- (void)showInfo:(NSString *)text position:(id)position;

@end

NS_ASSUME_NONNULL_END
